//测试菲涅尔效果的像素着色器

//顶点着色器输出
struct VS_OUTPUT
{
    float4 Pos : SV_POSITION;
    float3 Normal : NORMAL;
	float2 TexCoord : TEXCOORD0;
	float3 WorldPosition : TEXCOORD1;
};

Texture2D ourTexture : register( t9 );
SamplerState ourSampler : register( s5 );

cbuffer SceneData : register( b7 )
{
	matrix View;
	matrix Projection;
	float4 lightDir;
	float4 eyePosition;
}

float4 Main( VS_OUTPUT input ) : SV_Target
{
	//视线方向
	float3 EyeDir = eyePosition.xyz - input.WorldPosition;
	
	//法线点乘视线
	float NdE = dot(normalize(input.Normal),normalize(EyeDir));
	
	//菲涅尔系数
	float fresnel = 1.0 - NdE;
	
	//将菲涅尔系数做指数变化使得效果更明显
	fresnel = pow(fresnel,3);
	
	return float4(fresnel,fresnel,fresnel,1.0);
}
